<?php

class customerOverview extends bee\form
{ protected static $__formID = "frm201201272252";
  //public $__caption = "Customer overview";
  //public $__version = "1.0";

  protected $customer;
  protected $afWh;
  protected $description;
/**
 * @todo if grid comes over tdescription then following error is shown:
 * Notice: unserialize() [function.unserialize]: Error at offset 3834 of 6565 bytes in /home/dysback/lib/factory.php on line 14
 * sholud be investigated
 */
  protected $tDescription;
  protected $grid;




  public function createForm($evt)
  { $this->__caption = "Customer overview";
    $this->__version = "1.0";
    $this->customer = new bee\org_unit();
    $this->grid = custGrid::getInstance();
    $this->grid->setDataSource($this->customer);
    $this->grid->setColumnProperties(array("name" => "id", "caption" => "name", "width" => 100));
    $this->grid->setColumnProperties(array("name" => "description", "caption" => "Description", "width" => 300));
    $this->grid->detailFormName = "editCustomer";

    $this->tDescription = new bee\text("description", $this->description);
    //$this->tDescription = new bee\text("description", $this->description);
  }

  public function grid_filter($evt)
  { $this->description = $evt["description"];
    $pdescription = "%$this->description%";
    $this->afWh = new bee\afterWhere();
    $this->afWh->text .= " AND (name like :description1 OR description like :description2) ";
    $this->afWh->setParam("description1", $pdescription, PDO::PARAM_STR);
    $this->afWh->setParam("description2", $pdescription, PDO::PARAM_STR);
    $this->grid->setDataSource($this->customer, $this->afWh);
  }
}

class custGrid extends bee\grid
{
  public function createGrid($evt)
  { $this->__gridID = "grd201201272353";
  }
}
